﻿// Decompiled with JetBrains decompiler
// Type: System.Web.Razor.Parser.CSharpLanguageCharacteristics
// Assembly: System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// MVID: 682513D6-F37E-48AC-9909-F3EE103CFF14
// Assembly location: D:\Project\Idea\无人机外网\uav\客户端工程\排查工具\bin\Release\System.Web.Razor.dll

using System.Collections.Generic;
using System.Web.Razor.Parser.SyntaxTree;
using System.Web.Razor.Resources;
using System.Web.Razor.Text;
using System.Web.Razor.Tokenizer;
using System.Web.Razor.Tokenizer.Symbols;

namespace System.Web.Razor.Parser
{
  /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Represents the different language characteristics in a CSharp language.</summary>
  public class CSharpLanguageCharacteristics : 
    LanguageCharacteristics<CSharpTokenizer, CSharpSymbol, CSharpSymbolType>
  {
    private static readonly CSharpLanguageCharacteristics _instance = new CSharpLanguageCharacteristics();
    private static Dictionary<CSharpSymbolType, string> _symbolSamples = new Dictionary<CSharpSymbolType, string>()
    {
      {
        CSharpSymbolType.Arrow,
        "->"
      },
      {
        CSharpSymbolType.Minus,
        "-"
      },
      {
        CSharpSymbolType.Decrement,
        "--"
      },
      {
        CSharpSymbolType.MinusAssign,
        "-="
      },
      {
        CSharpSymbolType.NotEqual,
        "!="
      },
      {
        CSharpSymbolType.Not,
        "!"
      },
      {
        CSharpSymbolType.Modulo,
        "%"
      },
      {
        CSharpSymbolType.ModuloAssign,
        "%="
      },
      {
        CSharpSymbolType.AndAssign,
        "&="
      },
      {
        CSharpSymbolType.And,
        "&"
      },
      {
        CSharpSymbolType.DoubleAnd,
        "&&"
      },
      {
        CSharpSymbolType.LeftParenthesis,
        "("
      },
      {
        CSharpSymbolType.RightParenthesis,
        ")"
      },
      {
        CSharpSymbolType.Star,
        "*"
      },
      {
        CSharpSymbolType.MultiplyAssign,
        "*="
      },
      {
        CSharpSymbolType.Comma,
        ","
      },
      {
        CSharpSymbolType.Dot,
        "."
      },
      {
        CSharpSymbolType.Slash,
        "/"
      },
      {
        CSharpSymbolType.DivideAssign,
        "/="
      },
      {
        CSharpSymbolType.DoubleColon,
        "::"
      },
      {
        CSharpSymbolType.Colon,
        ":"
      },
      {
        CSharpSymbolType.Semicolon,
        ";"
      },
      {
        CSharpSymbolType.QuestionMark,
        "?"
      },
      {
        CSharpSymbolType.NullCoalesce,
        "??"
      },
      {
        CSharpSymbolType.RightBracket,
        "]"
      },
      {
        CSharpSymbolType.LeftBracket,
        "["
      },
      {
        CSharpSymbolType.XorAssign,
        "^="
      },
      {
        CSharpSymbolType.Xor,
        "^"
      },
      {
        CSharpSymbolType.LeftBrace,
        "{"
      },
      {
        CSharpSymbolType.OrAssign,
        "|="
      },
      {
        CSharpSymbolType.DoubleOr,
        "||"
      },
      {
        CSharpSymbolType.Or,
        "|"
      },
      {
        CSharpSymbolType.RightBrace,
        "}"
      },
      {
        CSharpSymbolType.Tilde,
        "~"
      },
      {
        CSharpSymbolType.Plus,
        "+"
      },
      {
        CSharpSymbolType.PlusAssign,
        "+="
      },
      {
        CSharpSymbolType.Increment,
        "++"
      },
      {
        CSharpSymbolType.LessThan,
        "<"
      },
      {
        CSharpSymbolType.LessThanEqual,
        "<="
      },
      {
        CSharpSymbolType.LeftShift,
        "<<"
      },
      {
        CSharpSymbolType.LeftShiftAssign,
        "<<="
      },
      {
        CSharpSymbolType.Assign,
        "="
      },
      {
        CSharpSymbolType.Equals,
        "=="
      },
      {
        CSharpSymbolType.GreaterThan,
        ">"
      },
      {
        CSharpSymbolType.GreaterThanEqual,
        ">="
      },
      {
        CSharpSymbolType.RightShift,
        ">>"
      },
      {
        CSharpSymbolType.RightShiftAssign,
        ">>>"
      },
      {
        CSharpSymbolType.Hash,
        "#"
      },
      {
        CSharpSymbolType.Transition,
        "@"
      }
    };

    private CSharpLanguageCharacteristics()
    {
    }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets the instance for the <see cref="T:System.Web.Razor.Parser.CSharpLanguageCharacteristics" /> class.</summary>
    /// <returns>The instance for the <see cref="T:System.Web.Razor.Parser.CSharpLanguageCharacteristics" /> class.</returns>
    public static CSharpLanguageCharacteristics Instance => CSharpLanguageCharacteristics._instance;

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Creates a language tokenizer.</summary>
    /// <returns>A language tokenizer.</returns>
    /// <param name="source">The source of the text document.</param>
    public override CSharpTokenizer CreateTokenizer(ITextDocument source) => new CSharpTokenizer(source);

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Creates a symbol in the code.</summary>
    /// <returns>A symbol in the code.</returns>
    /// <param name="location">The source location.</param>
    /// <param name="content">The content value.</param>
    /// <param name="type">The html symbol type.</param>
    /// <param name="errors">List of errors.</param>
    protected override CSharpSymbol CreateSymbol(
      SourceLocation location,
      string content,
      CSharpSymbolType type,
      IEnumerable<RazorError> errors)
    {
      return new CSharpSymbol(location, content, type, errors);
    }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets a sample symbol in the code.</summary>
    /// <returns>A sample symbol in the code.</returns>
    /// <param name="type">The <see cref="T:System.Web.Razor.Tokenizer.Symbols.HtmlSymbolType" />.</param>
    public override string GetSample(CSharpSymbolType type) => CSharpLanguageCharacteristics.GetSymbolSample(type);

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Creates a marker symbol in the code.</summary>
    /// <returns>A marker symbol in the code.</returns>
    /// <param name="location">The source location.</param>
    public override CSharpSymbol CreateMarkerSymbol(SourceLocation location) => new CSharpSymbol(location, string.Empty, CSharpSymbolType.Unknown);

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets the <see cref="T:System.Web.Razor.Parser.CSharpLanguageCharacteristics" /> in the code.</summary>
    /// <returns>The <see cref="T:System.Web.Razor.Parser.CSharpLanguageCharacteristics" /> in the code.</returns>
    /// <param name="type">The <see cref="T:System.Web.Razor.Tokenizer.Symbols.KnownSymbolType" />.</param>
    public override CSharpSymbolType GetKnownSymbolType(KnownSymbolType type)
    {
      switch (type)
      {
        case KnownSymbolType.WhiteSpace:
          return CSharpSymbolType.WhiteSpace;
        case KnownSymbolType.NewLine:
          return CSharpSymbolType.NewLine;
        case KnownSymbolType.Identifier:
          return CSharpSymbolType.Identifier;
        case KnownSymbolType.Keyword:
          return CSharpSymbolType.Keyword;
        case KnownSymbolType.Transition:
          return CSharpSymbolType.Transition;
        case KnownSymbolType.CommentStart:
          return CSharpSymbolType.RazorCommentTransition;
        case KnownSymbolType.CommentStar:
          return CSharpSymbolType.RazorCommentStar;
        case KnownSymbolType.CommentBody:
          return CSharpSymbolType.RazorComment;
        default:
          return CSharpSymbolType.Unknown;
      }
    }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Flips the bracket symbol in the code.</summary>
    /// <returns>The bracket symbol in the code.</returns>
    /// <param name="bracket">The symbol bracket.</param>
    public override CSharpSymbolType FlipBracket(CSharpSymbolType bracket)
    {
      switch (bracket)
      {
        case CSharpSymbolType.LeftParenthesis:
          return CSharpSymbolType.RightParenthesis;
        case CSharpSymbolType.RightParenthesis:
          return CSharpSymbolType.LeftParenthesis;
        case CSharpSymbolType.RightBracket:
          return CSharpSymbolType.LeftBracket;
        case CSharpSymbolType.LeftBracket:
          return CSharpSymbolType.RightBracket;
        case CSharpSymbolType.LeftBrace:
          return CSharpSymbolType.RightBrace;
        case CSharpSymbolType.RightBrace:
          return CSharpSymbolType.LeftBrace;
        case CSharpSymbolType.LessThan:
          return CSharpSymbolType.GreaterThan;
        case CSharpSymbolType.GreaterThan:
          return CSharpSymbolType.LessThan;
        default:
          return CSharpSymbolType.Unknown;
      }
    }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets the keyword in the code.</summary>
    /// <returns>The keyword in the code.</returns>
    /// <param name="keyword">The keyword.</param>
    public static string GetKeyword(CSharpKeyword keyword) => keyword.ToString().ToLowerInvariant();

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets a sample symbol in the code.</summary>
    /// <returns>A sample symbol in the code.</returns>
    /// <param name="type">The <see cref="T:System.Web.Razor.Tokenizer.Symbols.HtmlSymbolType" />.</param>
    public static string GetSymbolSample(CSharpSymbolType type)
    {
      string str;
      if (CSharpLanguageCharacteristics._symbolSamples.TryGetValue(type, out str))
        return str;
      switch (type)
      {
        case CSharpSymbolType.Identifier:
          return RazorResources.CSharpSymbol_Identifier;
        case CSharpSymbolType.Keyword:
          return RazorResources.CSharpSymbol_Keyword;
        case CSharpSymbolType.IntegerLiteral:
          return RazorResources.CSharpSymbol_IntegerLiteral;
        case CSharpSymbolType.NewLine:
          return RazorResources.CSharpSymbol_Newline;
        case CSharpSymbolType.WhiteSpace:
          return RazorResources.CSharpSymbol_Whitespace;
        case CSharpSymbolType.Comment:
          return RazorResources.CSharpSymbol_Comment;
        case CSharpSymbolType.RealLiteral:
          return RazorResources.CSharpSymbol_RealLiteral;
        case CSharpSymbolType.CharacterLiteral:
          return RazorResources.CSharpSymbol_CharacterLiteral;
        case CSharpSymbolType.StringLiteral:
          return RazorResources.CSharpSymbol_StringLiteral;
        default:
          return RazorResources.Symbol_Unknown;
      }
    }
  }
}
